<%--
  Created by IntelliJ IDEA.
  User: houxy
  Date: 2016/8/5
  Time: 10:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ include file="/WEB-INF/views/pageMenu/header.jsp" %>
<%@ include file="/WEB-INF/views/pageMenu/sidebar.jsp" %>
<%@ include file="/WEB-INF/views/pageMenu/footer.jsp" %>
<c:set var="isShowAll" value="${sessionScope.isShowAll}"/>
<html>
<head>
    <title>用户维护</title>
    <script src='<spring:url value="/resources/js/crypto-js.min.js"/>'></script>
    <script src='<spring:url value="/resources/js/cryptoUtil.js"/>'></script>
    <script src='<spring:url value="/resources/tree/maintainUser.js"></spring:url>'></script>
    <script src='<spring:url value="/resources/js/jquery-ui-1.10.4.custom.js" ></spring:url>'></script>
    <link rel="stylesheet" type="text/css"
          href='<spring:url value="/resources/zTreeStyle/zTreeStyle.css"></spring:url>'>
    <script src='<spring:url value="/resources/tree/jquery.ztree.core-3.4.js"></spring:url>'></script>
    <script src='<spring:url value="/resources/tree/jquery.ztree.excheck-3.4.js"></spring:url>'></script>

    <style type="text/css">
        ul {
            margin: 0 0;
        }

        .help-inline {
            width: 150px;
            text-align: right;
        }
    </style>
    <script>
        var isShowAll = "${isShowAll}";
        var userId = "<%=session.getAttribute("loginUserId") %>";
    </script>
</head>
<body>

<div class="pageinfo" style="margin-bottom: 50px;">
    <%--<div>--%>
    <%--<span class="page-title">用户维护</span>--%>
    <%--</div>--%>
    <ul class="breadcrumb">
        <li>
            <i class="icon-home"></i>
            <a href="/auth/desktop">主页</a>
            <i class="icon-angle-right"></i>
        </li>
        <li>
            <a style="text-decoration: none">维护</a>
            <i class="icon-angle-right"></i>
        </li>
        <li>
            <a href="${url}">用户维护</a>
        </li>
    </ul>
    <div class="top-menu">
        <form action='${ctx}/toUserMaintain' method="post" id="findAppealForm">
            <div class="form-inline" style="margin-top: 10px;">
                <span class="font-yh">用户名：</span><input type="text" name="searchUserName" value="${searchUserName}"
                                                        class="small m-wrap">
                <span class="font-yh">姓名：</span><input type="text" name="compelltion" value="${compelltion}"
                                                       class="small m-wrap">
                <span class="font-yh" for="">部门：</span>
                <select name="deptId" class="m-wrap" style="width: 160px;height: 30px !important;">
                    <option value="all">全部</option>
                    <c:forEach items="${orgs}" var="o">
                        <option ${deptId==o.id?"selected":""} value="${o.id}">${o.name}</option>
                    </c:forEach>
                </select>
                <button class="btn blue" type="submit" id="search"><i class="icon-search">查询</i></button>
            </div>
        </form>
    </div>
    <div style="">
        <a class="btn" id="add_role" data-toggle="modal" href="#responsive1" onclick="save()"><i class="icon-plus"></i>新增</a>
        <table class="plan-table table-striped table-hover">
            <tr>
                <th>用户名</th>
                <th>姓名</th>
                <th>部门</th>
                <th>操作</th>
            </tr>
            <c:forEach items="${users}" var="u">
                <tr>
                    <td>${u.username}</td>
                    <td>${u.compelltion}</td>
                    <td>${u.orgName}</td>
                    <td>
                        <c:choose>
                            <c:when test="${u.username=='admin'}">
                                无法操作
                            </c:when>
                            <c:otherwise>
                                <a data-toggle="modal" href="#responsive2" onclick="alterUser('${u.id}');">
                                    <span><i class="icon-pencil">修改</i></span>
                                </a>
                                <a onclick="delUser('${u.id}');" href="javascript:">
                                    <span><i class="icon-trash">删除</i></span>
                                </a>
                                <a onclick="forceResetPassword('${u.id}');" href="javascript:">
                                    <span><i class="icon-refresh">重置登录密码</i></span>
                                </a>
                            </c:otherwise>
                        </c:choose>
                    </td>
                </tr>
            </c:forEach>
            <c:if test="${fn:length(users) < 15}">
                <c:forEach begin="1" end="${15-fn:length(users)}" var="i">
                    <tr>
                        <td>&nbsp;&nbsp;</td>
                        <td>&nbsp;&nbsp;</td>
                        <td>&nbsp;&nbsp;</td>
                        <td>&nbsp;&nbsp;</td>
                    </tr>
                </c:forEach>
            </c:if>
        </table>
        <div class="pagemenu">
            <jsp:include page="page.jsp">
                <jsp:param name="formId" value="findAppealForm"/>
            </jsp:include>
        </div>
    </div>
</div>

<!-- 模态框新建开始 -->
<div id="responsive1" class="modal hide fade" tabindex="-1" data-width="760">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
        <h3>新建</h3>
    </div>

    <div class="modal-body">
        <div class="form-inline">
            <label for="" class="help-inline">用户名：</label>
            <input type="text" id="username" style="height:30px;"/><span class="validTip">*</span>
        </div>
        <div class="form-inline m-top-10">
            <label for="" class="help-inline">姓名：</label>
            <input type="text" id="compelltion" style="height:30px;"/><span class="validTip">*</span>
        </div>
        <div class="form-inline m-top-10">
            <label for="" class="help-inline">密码：</label>
            <input type="password" id="password" style="height:30px;"/><span class="validTip">*</span>
        </div>
        <div class="form-inline m-top-10">
            <label for="" class="help-inline">确认密码：</label>
            <input type="password" id="surePassword" style="height:30px;"/><span class="validTip">*</span>
        </div>
        <div class="form-inline m-top-10">
            <label for="" class="help-inline">部门：</label>
            <div style="border: 1px solid #CCC;width: 204px;height: 150px; overflow: auto;display: inline-block;vertical-align: top">
                <ul id="treeDemo" class="ztree"></ul>
                <input type="hidden" id="orgId" value="">
            </div>
            <span class="validTip">*</span>
        </div>
        <div class="form-inline m-top-10">
            <label for="" class="help-inline">选择权限：</label>
            <div style="border: 1px solid #CCC;width: 206px;height: 70px; overflow: auto;display: inline-block;vertical-align: top">
                <ul id="roles"></ul>
            </div>
        </div>
        <div class="form-inline m-top-10" style="width: 204px;margin: auto">
            <label style="color: red;font-weight: bold;">
                注：<br/>
                选择“普通”，用户可维护当前飞行队人员及组织结构<br/>
                选择“总调”，可维护所有飞行队人员及组织结构
            </label>
        </div>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn blue" onclick="saveUser();">添加</button>
        <button type="button" data-dismiss="modal" onclick="cancleAction();" class="btn">关闭</button>
    </div>
</div>
<!-- 模态框新建结束 -->

<!-- 模态框修改开始 -->
<div id="responsive2" class="modal hide fade" tabindex="-1" data-width="760">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
        <h3>修改</h3>
    </div>
    <div class="modal-body">
        <div class="form-inline">
            <label for="" class="help-inline">姓名：</label>
            <input type="text" id="Nowcompelltion" style="height:30px;"/><span class="validTip">*</span>
        </div>
        <div class="form-inline m-top-10">
            <label for="" class="help-inline">用户名：</label>
            <input type="text" id="NowUserName" style="height:30px;" readonly/>
        </div>
        <input type="hidden" id="userId" value="">
        <div class="form-inline m-top-10">
            <label for="" class="help-inline">当前部门：</label>
            <input type="text" id="NowDept" style="height:30px;" readonly/>
        </div>
        <div class="form-inline m-top-10">
            <label for="" class="help-inline">转到：</label>
            <div style="border: 1px solid #CCC;width: 206px;height: 150px;overflow: auto;display: inline-block;vertical-align: top">
                <ul id="treeDemo1" class="ztree"></ul>
                <input type="hidden" id="orgId1" value="">
            </div>
        </div>
        <div class="form-inline m-top-10">
            <label for="" class="help-inline">选择权限：</label>
            <div style="border: 1px solid #CCC;width: 206px;height: 70px; overflow: auto;display: inline-block;vertical-align: top">
                <ul id="roles1"></ul>
            </div>
        </div>
        <div class="form-inline m-top-10" style="width: 204px;margin: auto">
            <label style="color: red;font-weight: bold;">
                注：<br/>
                选择“普通”，用户可维护所属飞行队人员及组织结构。<br/>
                选择“总调”，可维护所有飞行队人员及组织结构。
            </label>
        </div>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn blue" onclick="moveUser();">保存</button>
        <button type="button" data-dismiss="modal" onclick="cancleAction();" class="btn">关闭</button>
    </div>
</div>
<!-- 模态框修改结束 -->
<script>
    $(document).ready(function () {
        $("#userMaintain").attr("class", "active");
        $("#userMaintain").parent().parent().addClass("open").addClass("active");
    });
</script>
</body>
</html>